home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks95
/
Aaron 1.0b3.sit
/
Aaron 1.0b3
/
Aaron Source
/
CDEF and Patches
/
DrawButton.c
< prev
next >
Wrap
Text File
|
1995-06-24
|
9KB
|
282 lines
/* Aaron © 1995 Gregory D. Landweber, ALL RIGHTS RESERVED */
#include "CDEF.h"
#include <Icons.h>
void WindowBack ( WindowPtr theWindow, RGBColor *theColor );
pascal void DrawDevelopButton ( GregInfo *theInfo );
void DrawOldStyle ( GregInfo *theInfo, short fore, short back );
void GrayForeColor ( short index );
void GrayBackColor ( short index );
void WindowBack ( WindowPtr theWindow, RGBColor *theColor )
{
AuxWinHandle theAuxWin;
GetAuxWin ( theWindow, &theAuxWin );
GetPartColor ( *(*theAuxWin)->awCTable, theColor, wContentColor );
}
pascal void DrawIcon ( short depth, short deviceFlags,
GDHandle targetDevice, GregInfo *theInfo )
{
Rect theRect = { 0, 0, ButtonSize, ButtonSize };
CIconHandle theIcon;
RGBColor theColor;
// normal, hilited, disabled
short iconID[2][3][2] = { { { -20239, -20236 }, { -20238, -20235 }, { -20240, -20237 } }, // check
{ { -20215, -20214 }, { -20213, -20212 }, { -20211, -20210 } } }; // radio
short buttonHilite, buttonValue;
WindowBack ( (*(theInfo->theControl))->contrlOwner, &theColor );
RGBBackColor ( &theColor );
if ( LoWord(theInfo->msgParam) == inNone )
EraseRect ( &theInfo->theRect );
DrawTitle ( theInfo, false, false, false );
OffsetRect ( &theRect, theInfo->theRect.left + ButtonLeft,
( theInfo->theRect.bottom + theInfo->theRect.top - ButtonSize ) >> 1 );
buttonValue = (*(theInfo->theControl))->contrlValue;
buttonHilite = 0;
if ( theInfo->pushed )
buttonHilite = 1;
if ( theInfo->inActive )
buttonHilite = 2;
theIcon = GetCIcon ( iconID [theInfo->radio][buttonHilite][buttonValue] );
if ( theIcon ) {
if ( !theInfo->radio )
EraseRect (&theRect);
PlotCIcon (&theRect, theIcon);
DisposCIcon (theIcon);
}
}
void DrawOldStyle ( GregInfo *theInfo, short fore, short back )
{
GrayBackColor ( back );
GrayForeColor ( fore );
EraseRoundRect ( &theInfo->theRect, Radius, Radius );
FrameRoundRect ( &theInfo->theRect, Radius, Radius );
DrawTitle ( theInfo, false, false, theInfo->pushed );
return;
}
pascal void DrawButton (short depth, short deviceFlags, GDHandle targetDevice, GregInfo *theInfo)
{
if ( ( theInfo->theRect.bottom - theInfo->theRect.top < 6 ) ||
( theInfo->theRect.right - theInfo->theRect.left < 6 ) ) {
if ( ( depth >= 4 ) && !theInfo->pushed )
DrawOldStyle ( theInfo, iFrameColor, 0x0D );
else
DrawOldStyle ( theInfo, iFrameColor, 0x0F );
return;
}
if ( depth < 4 ) {
DrawOldStyle ( theInfo, iFrameColor, theInfo->pushed ? 0x00 : 0x0F );
return;
}
DrawDevelopButton ( theInfo );
}
pascal void DrawDevelopButton ( GregInfo *theInfo )
{
GrayBackColor ( theInfo->pushed ? 0x08 : 0x0D );
if ( theInfo->inActive ) {
Rect theRect = theInfo->theRect;
GrayBackColor ( 0x0D );
GrayForeColor ( 0x08 );
EraseRoundRect ( &theRect, Radius, Radius );
FrameRoundRect ( &theRect, Radius, Radius );
DrawTitle ( theInfo, false, false, false );
InsetRect ( &theRect, 1, 1 );
GrayForeColor ( 0x0A );
MoveTo ( theRect.left + 2, theRect.bottom - 1 );
LineTo ( theRect.right - 2, theRect.bottom - 1 );
LineTo ( theRect.right - 1, theRect.bottom - 2 );
LineTo ( theRect.right - 1, theRect.top + 2 );
MoveTo ( theRect.right - 2, theRect.bottom - 2 );
Line ( 0, 0 );
GrayForeColor ( 0x0B );
MoveTo ( theRect.left + 1, theRect.bottom - 1 );
LineTo ( theRect.left, theRect.bottom - 2 );
MoveTo ( theRect.left, theRect.top + 1 );
LineTo ( theRect.left + 1, theRect.top );
MoveTo ( theRect.right - 2, theRect.top );
LineTo ( theRect.right - 1, theRect.top + 1 );
InsetRect ( &theRect, 1, 1 );
GrayForeColor ( 0x0F );
MoveTo ( theRect.left, theRect.bottom - 2 );
LineTo ( theRect.left, theRect.top );
LineTo ( theRect.right - 2, theRect.top );
MoveTo ( theRect.left + 1, theRect.top + 1 );
Line ( 0, 0 );
GrayForeColor ( 0x0B );
MoveTo ( theRect.left + 1, theRect.bottom - 1 );
LineTo ( theRect.right - 2, theRect.bottom - 1 );
LineTo ( theRect.right - 1, theRect.bottom - 2 );
LineTo ( theRect.right - 1, theRect.top + 1 );
MoveTo ( theRect.right - 2, theRect.bottom - 2 );
Line ( 0, 0 );
return;
}
GrayForeColor ( 0x00 );
EraseRoundRect ( &theInfo->theRect, Radius, Radius );
FrameRoundRect ( &theInfo->theRect, Radius, Radius );
DrawTitle ( theInfo, false, false, false );
if ( theInfo->pushed ) {
Rect theRect = theInfo->theRect;
InsetRect ( &theRect, 1, 1 );
GrayForeColor ( 0x04 );
MoveTo ( theRect.left, theRect.bottom - 3 );
LineTo ( theRect.left, theRect.top + 2 );
MoveTo ( theRect.left + 2, theRect.top );
LineTo ( theRect.right - 3, theRect.top );
GrayForeColor ( 0x0C );
MoveTo ( theRect.left + 2, theRect.bottom - 1 );
LineTo ( theRect.right - 2, theRect.bottom - 1 );
MoveTo ( theRect.right - 1, theRect.bottom - 2 );
LineTo ( theRect.right - 1, theRect.top + 2 );
MoveTo ( theRect.right - 2, theRect.bottom - 2 );
Line ( 0, 0 );
GrayForeColor ( 0x05 );
MoveTo ( theRect.left + 1, theRect.bottom - 1 );
LineTo ( theRect.left, theRect.bottom - 2 );
MoveTo ( theRect.left, theRect.top + 1 );
LineTo ( theRect.left + 1, theRect.top );
MoveTo ( theRect.right - 2, theRect.top );
LineTo ( theRect.right - 1, theRect.top + 1 );
InsetRect ( &theRect, 1, 1 );
GrayForeColor ( 0x05 );
MoveTo ( theRect.left, theRect.bottom - 2 );
LineTo ( theRect.left, theRect.top );
LineTo ( theRect.right - 2, theRect.top );
MoveTo ( theRect.left + 1, theRect.top + 1 );
Line ( 0, 0 );
GrayForeColor ( 0x0A );
MoveTo ( theRect.left + 1, theRect.bottom - 1 );
LineTo ( theRect.right - 2, theRect.bottom - 1 );
MoveTo ( theRect.right - 1, theRect.bottom - 2);
LineTo ( theRect.right - 1, theRect.top + 1 );
MoveTo ( theRect.right - 2, theRect.bottom - 2 );
Line ( 0, 0 );
}
else {
Rect theRect = theInfo->theRect;
InsetRect ( &theRect, 1, 1 );
GrayForeColor ( 0x07 );
MoveTo ( theRect.left + 2, theRect.bottom - 1);
LineTo ( theRect.right - 2, theRect.bottom - 1);
MoveTo ( theRect.right - 1, theRect.bottom - 2 );
LineTo ( theRect.right - 1, theRect.top + 2);
MoveTo ( theRect.right - 2, theRect.bottom - 2 );
Line ( 0, 0 );
GrayForeColor ( 0x0A );
MoveTo ( theRect.left + 1, theRect.bottom - 1 );
LineTo ( theRect.left, theRect.bottom - 2 );
MoveTo ( theRect.left, theRect.top + 1 );
LineTo ( theRect.left + 1, theRect.top );
MoveTo ( theRect.right - 2, theRect.top );
LineTo ( theRect.right - 1, theRect.top + 1 );
InsetRect ( &theRect, 1, 1 );
GrayForeColor ( 0x0F );
MoveTo ( theRect.left, theRect.bottom - 2 );
LineTo ( theRect.left, theRect.top );
LineTo ( theRect.right - 2, theRect.top );
MoveTo ( theRect.left + 1, theRect.top + 1 );
Line ( 0, 0 );
GrayForeColor ( 0x0A );
MoveTo ( theRect.left + 1, theRect.bottom - 1 );
LineTo ( theRect.right - 2, theRect.bottom - 1 );
MoveTo ( theRect.right - 1, theRect.bottom - 2 );
LineTo ( theRect.right - 1, theRect.top + 1 );
MoveTo ( theRect.right - 2, theRect.bottom - 2 );
Line ( 0, 0 );
}
DrawTitle ( theInfo, true, false, false );
DrawTitle ( theInfo, false, false, false );
GrayForeColor ( 0x00 );
FrameRoundRect ( &theInfo->theRect, Radius, Radius );
{
Rect theRect = theInfo->theRect;
GrayForeColor ( 0x02 );
MoveTo ( theRect.left + 2, theRect.top );
Line ( 0, 0 );
MoveTo ( theRect.left, theRect.top + 2 );
Line ( 0, 0 );
MoveTo ( theRect.right - 3, theRect. top );
Line ( 0, 0 );
MoveTo ( theRect.right - 1, theRect.top + 2 );
Line ( 0, 0 );
MoveTo ( theRect.left + 2, theRect.bottom - 1 );
Line ( 0, 0 );
MoveTo ( theRect.left, theRect.bottom - 3 );
Line ( 0, 0 );
MoveTo ( theRect.right - 3, theRect.bottom - 1);
Line ( 0, 0 );
MoveTo ( theRect.right - 1, theRect.bottom - 3 );
Line ( 0, 0 );
/*
GrayForeColor ( 0x07 );
MoveTo ( theRect.left, theRect.top + 1 );
LineTo ( theRect.left + 1, theRect.top );
MoveTo ( theRect.right - 2, theRect.top );
LineTo ( theRect.right - 1, theRect.top + 1 );
MoveTo ( theRect.right - 1, theRect.bottom - 2 );
LineTo ( theRect.right - 2, theRect.bottom - 1 );
MoveTo ( theRect.left + 1, theRect.bottom - 1 );
LineTo ( theRect.left, theRect.bottom - 2 );
*/
}
}
void GrayForeColor ( short index )
{
RGBColor theColor;
theColor.red = theColor.green = theColor.blue = 0x1111 * index;
RGBForeColor ( &theColor );
}
void GrayBackColor ( short index )
{
RGBColor theColor;
theColor.red = theColor.green = theColor.blue = 0x1111 * index;
RGBBackColor ( &theColor );
}